import { useDateFormat } from "@vueuse/core";

export const userNameRender: any = (userId: string, dataList) => {
  if (dataList && dataList.length > 0) {
    return dataList.find(user => user._id === userId)?.userName || "未知用户";
  }
  return "未知用户";
};

export const userPicIdRender: any = (userId: string, dataList) => {
  if (dataList && dataList.length > 0) {
    return dataList.find(user => user._id === userId)?.userPicId || "";
  }
  return "";
};

export const timeRender: any = (date: Date) => {
  if (!date) return "";
  return useDateFormat(date, "YYYY-MM-DD HH:mm:ss").value;
};

export const enumNameRender: any = (enumValue: string, enumList: any[]) => {
  if (enumList && enumList.length > 0) {
    const enumItem = enumList.find(item => item.value === enumValue);
    return enumItem ? enumItem.name : "未知";
  }
  return "未知";
};

export const enumTagRender: any = (enumValue: string, enumList: any[]) => {
  if (enumList && enumList.length > 0) {
    const enumItem = enumList.find(item => item.value === enumValue);
    return enumItem ? enumItem.tagType : "info";
  }
  return "info";
};
